﻿@model SchoolCommunicationSystem.Models.LearnerAndClassModels
@{
    Layout = null;
}
@*
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
*@

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.ui.datepicker-vi-VN.js")" type="text/javascript"></script>
<script>
$(function () {
    $.validator.addMethod('date',
    function (value, element) {
        if (this.optional(element)) {
            return true;
        }
        var ok = true;
        try {
            $.datepicker.parseDate('dd/mm/yy', value);
        }
        catch (err) {
            ok = false;
        }
        return ok;
    });
    $(".datefield").datepicker({ dateFormat: 'dd/mm/yy', yearRange: '1950:2020', changeYear: true, changeMonth: true });
});
</script>
@*@using (Ajax.BeginForm("EditCustomer", "Home", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "edit-Dialog" }))*@
@using (Html.BeginForm("CreateEditLearner", "Learner", "POST"))
{  
    <fieldset>
        <legend>Học sinh</legend>
        @* <div style="color: Green; font-weight: bold">
            @ViewBag.Msg
        </div>*@
        @if (ViewBag.IsUpdate == true)
        { 
            @Html.HiddenFor(model => model.Learners.learnerID)
            @Html.HiddenFor(m => m.Learners.parentID)
        }
        @if (ViewBag.IsUpdate != true)
        {
            <div class="editor-label">
                @Html.Label("Lớp")
            </div>
            <div class="editor-field">
                @Html.DropDownListFor(model => model.Learners.classID, Model.ClassSelectList, "[Hãy chọn lớp học]")
                @Html.ValidationMessageFor(model => model.Learners.classID)
            </div>
        }
        else
        {
            <div class="editor-label">
                @Html.Label("Lớp")
            </div>
            <div class="editor-field">
                @Html.DropDownListFor(model => model.Learners.classID, Model.ClassSelectList, "[Hãy chọn lớp học]")
                @Html.ValidationMessageFor(model => model.Learners.classID)
            </div>
        }
        <div class="editor-label">
            @Html.Label("Họ đệm")
        </div>

        <div class="editor-field">
            @Html.EditorFor(model => model.Learners.firstName)
            @Html.ValidationMessageFor(model => model.Learners.firstName)
        </div>
        <div class="editor-label">
            @Html.Label("Tên")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Learners.lastName)
            @Html.ValidationMessageFor(model => model.Learners.lastName)
        </div>
        <div class="editor-label">
            @Html.Label("Ngày sinh")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Learners.dateOfBirth)
            @Html.ValidationMessageFor(model => model.Learners.dateOfBirth)
        </div>
        <div class="editor-label">
            @Html.Label("Địa chỉ")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Learners.address)
            @Html.ValidationMessageFor(model => model.Learners.address)
        </div>
        <div class="editor-label">
            @Html.Label("Giới tính")
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Learners.gender, (IEnumerable<SelectListItem>)ViewBag.Genders)
        </div>
        <div class="editor-label">
            @Html.Label("Nơi sinh")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Learners.birthPlace)
            @Html.ValidationMessageFor(model => model.Learners.birthPlace)
        </div>
        @*   <div class="editor-label">
            @Html.LabelFor(model => model.dateOfBirth)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.dateOfBirth)
            @Html.ValidationMessageFor(model => model.dateOfBirth)
        </div>
      *@
        <br />
        <div style="float: right; margin-right: 25px; margin-top: 9px">
            @if (ViewBag.IsUpdate == true)
            { 

                <button type="submit" id="btnUpdate" name="Command" value="Update" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only">
                    <span class="ui-button-text">Cập nhật</span></button>
            }
            else
            { 
                <button type="submit" id="btnSave" name="Command" value="Save" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only">
                    <span class="ui-button-text">Tạo</span></button>
            }
            @*&nbsp; &nbsp;
            <button type="button" id="btncancel" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only">
                <span class="ui-button-text">Hủy</span></button>*@
        </div>
    </fieldset>
}
